package com.gp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

@Configuration
public class SwaggerConfig {
    //获取Swagger2的实例对象Docket。
    @Bean
    public Docket getDocket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("qy143").apiInfo(apiInfo())
                .select()
                //为指定的包生成api文档
                .apis(RequestHandlerSelectors.basePackage("com.gp.controller"))
                //为指定的路径生成api文档
                //.paths(PathSelectors.any())
                .build();
        return docket;
    }

    private ApiInfo apiInfo(){
        Contact DEFAULT_CONTACT = new Contact("七组", "http://www.baid.com", "473000@qq.com");
        ApiInfo apiInfo = new ApiInfo("QY143七组租车管理", "QY143七组租车员工管理", "2.0",
                "http://www.jd.com",
                DEFAULT_CONTACT, "AAA教育", "http://www.aaa.com", new ArrayList<VendorExtension>());
        return apiInfo;
    }
}